package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliveryAddressMapper {
    /**
     * 根据用户id查询地址
     * @param userId
     * @return
     */
    @Select("select *from deliveryAddress where userId=#{userId} order by daId ")
    public List<DeliveryAddress> listDeliveryAddressMapperByUserId(String userId);

    /**
     * 根据id查询
     * @param daId
     * @return
     */
    @Select("select *from deliveryAddress where daId#{daId}")
    public DeliveryAddress getDeliveryAddressById(Integer daId);

    /**
     * 添加
     * @param deliveryAddress
     * @return
     */
    @Insert("insert into deliveryAddress(contactName,contactSex,contactTel,address,userId) values(#{contactName}),#{contactSex},#{contactTel},#{address},#{userId}")
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress);

    /**
     * 修改
     * @param deliveryAddress
     * @return
     */
    @Update("update deliveryAddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address} where daId#{daId}")
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress);

    /**
     * 删除
     * @param deliveryAddress
     * @return
     */
    @Delete("delete from deliveryAddress where daId#{daId} ")
    public int deleteDeliveryAddress (DeliveryAddress deliveryAddress);
}